<template>
	<view>
		<view class="out">
			<image :src="userInfo.avatar"></image>
			<text>{{userInfo.nickname}}</text>
		</view>

		<view class="list">
<!-- 			<myList></myList>
			<myList></myList> -->
			<uv-list>
				<uv-list-item title="修改个人信息" link to="/pages/me/edit"></uv-list-item>
				<uv-list-item title="企业预警通" :note="qUserInfo" border></uv-list-item>
				<uv-list-item title="关于小程序" link @click="openPop" right-text="版本号" border></uv-list-item>
			</uv-list>
			<uv-modal ref="aboutPopup" title="关于" :content='introduction'></uv-modal>
			<button type="warn" @click="onLogout">退出登录</button>
		</view>
    <!-- <button type="primary" @click="jTest">测试JWT</button> -->
	</view>
</template>
<script setup>
	import nx from "@/nx"
	import {computed, ref} from "vue"
	import {onLoad} from '@dcloudio/uni-app'
	import getStorageItem from '@/utils/getStorageItem'
	const aboutPopup = ref(null)
	const userInfo = ref("")
	const introduction = ref("这是团队内部使用的一个小程序，目前正在搭建过程中。")
	const openPop = () => {
		aboutPopup.value.open()
    // console.log(version);
	}
  const version = import.meta.env.WX_APP_VERSION
	onLoad(()=>{
		// const userString = uni.getStorageSync('user')
		// const user = JSON.parse(userString)
		// console.log('user:',user);
		userInfo.value = getStorageItem('user')?.userInfo
		// console.log(userInfo.value);
	})
  const qUserInfo = computed(()=>{
    const phone = userInfo.value.qUserPhone
    return phone? "已绑定账号："+phone : "暂未绑定账号，请前往PC端绑定"
  })
  
  const onLogout = () => {
    // console.log('点击了登出');
    nx.$store('user').logout()
  }
//   // 测试jwt情况
//   const jTest = () => {
//     nx.$api.user.jwtTest()
//     nx.$api.user.jwtTest()
//     nx.$api.user.jwtTest()
//   }
</script>

<style lang="scss" scoped>
.out{
	width: 100%;
	height: 400rpx;
	background-color: #ccc;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	image{
		width: 150rpx;
		height: 150rpx;
		border-radius: 50%;
	}
	text{
		font-size: 30rpx;
		margin-top: 40rpx;
	}	
}
.list{
	margin: 60rpx 30rpx 0rpx;
	button{
		margin-top: 150rpx;
		width: 200rpx;
	}
}
</style>
